package text1;

import sun.security.action.GetPropertyAction;

import java.io.*;
import java.security.AccessController;

public class BufferDome {
    /**
     * 对字节输入流装饰缓冲流
     * @param args
     */
    public static void main(String[] args) {
//        text();
//        text_1();
//        text_2();
    }

    private static void text_2() {
        String ptt = "D:\\Path\\新建文件夹 (7)\\13.txt";
        try(
                Reader reader = new FileReader(ptt);
                BufferedReader bufferedReader = new BufferedReader(reader);
                ) {
            String itee;
            while ((itee = bufferedReader.readLine()) != null){
                System.out.println(itee);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void text_1() {
        //根据操作系统得到换行分隔符
        String s = AccessController.doPrivileged(
                new GetPropertyAction("line.separator"));
        System.out.println(s);
    }


    public static void text(){
                String str = "D:\\Path\\新建文件夹 (7)\\13.txt";
        try (
                Reader reader = new FileReader(str);
        ){
            char[] chars = new char[1024];
            int i;
            while ((i = reader.read(chars)) != -1){
                //将char转换为String
                String s = new String(chars, 0, i);
                System.out.println(s);
                
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
